#!/bin/bash

mainDir=`pwd`
testDir="${mainDir}/testy"
extIn="in"
inDir="${testDir}"
extOut="out"
outDir="${testDir}"
mainProgram="main"
tmpFileOut="${mainDir}/tmp.${extOut}"

gcc -o main main.c

if [ "$?" != "0" ]; then
	echo "build failed"
	exit
fi

cd ${inDir}

for fileIn in *.in
do

	echo "fileIn=$fileIn"

	fileName=${fileIn%.${extIn}}

#	echo "file name is: ${fileName}"

	fileOut=${outDir}/${fileName}.${extOut}

#	echo "file out is: ${fileOut}"

#	time 
	${mainDir}/${mainProgram} < ${fileIn} > ${tmpFileOut}
	diff -Z ${fileOut} ${tmpFileOut}
	
	if [ "$?" != "0" ]; then
		echo "${fileOut} AND ${tmpFileOut} ARE DIFFERENT !!"
		#exit
	fi
	
done

